
package com.monlyu.action.system;

import java.io.File;

import com.monlyu.action.BaseAction;
import com.monlyu.bo.AttachmentBo;

/********************************************************************************
 * <b>功能描述☞</b>上传文件的Action<br>
 * <b>开发公司☞</b>重庆唯尼科技有限公司<br>
 * <b>版权☞</b>本文件归重庆唯尼科技有限公司所有<br>
 * <b>项目名☞</b>monlyu<br>
 * <b>文件路径☞</b>com.monlyu.action.system.UploadFileAction.java<br>
 * <b>开发日期☞</b>2010-1-29 <br>
 * 
 * @author monlyu
 * @since JDK 5
 * @version 1.0.8
 ********************************************************************************/
public class UploadFileAction extends BaseAction {

    private AttachmentBo attachmentBo;

    public void setAttachmentBo(AttachmentBo attachmentBo){
        this.attachmentBo = attachmentBo;
    }

    @Override
    public String execute() throws Exception{
        String valString = attachmentBo.saveFile(file, fileFileName, fileContentType, fileDesc);
        return ajax(valString);
    }

    public String delete(){
        attachmentBo.deleteFile(id);
        return ajax("ok");
    }

    private Long id;
    private File file;
    private String fileContentType; // 上传文件的MIME类型
    private String fileFileName; // 上传文件的文件名，该文件名不包括文件的后缀
    private String fileDesc;

    public void setFile(File file){
        this.file = file;
    }

    public void setFileContentType(String fileContentType){
        this.fileContentType = fileContentType;
    }

    public Long getId(){
        return id;
    }

    public void setId(Long id){
        this.id = id;
    }

    public void setFileFileName(String fileFileName){
        this.fileFileName = fileFileName;
    }

    public String getFileDesc(){
        return fileDesc;
    }

    public void setFileDesc(String fileDesc){
        this.fileDesc = fileDesc;
    }
}
